home *** CD-ROM | disk | FTP | other *** search
/ The Best of Select: Games Special 4 / THE BEST OF SELECT Games Special 4 (Select CD-ROM)(1996).iso / dosgames / abuse / lisp / gates.lsp < prev    next >
Lisp/Scheme  |  1995-09-13  |  4KB  |  166 lines

  1. ;; Copyright 1995 Crack dot Com,  All Rights reserved
  2. ;; See licensing information for more details on usage rights
  3.  
  4. (defun delay_ai ()
  5.   (if (> (xvel) 0)
  6.       (progn
  7.     (set_xvel (- (xvel) 1))
  8.     (if (eq (xvel) 0)
  9.         (if (eq (state) stopped)
  10.         (progn
  11.           (set_aistate 1)
  12.           (set_state on_state))
  13.           (progn
  14.         (set_state stopped)
  15.         (set_aistate 0)))))
  16.     (if (> (total_objects) 0)
  17.     (if (eq (eq (aistate) 0) (eq (with_obj0 (aistate)) 0))
  18.       T
  19.     (set_xvel delay_time))))
  20. T)
  21.  
  22. (def_char GATE_DELAY
  23.   (funs (ai_fun delay_ai)
  24.     (draw_fun dev_draw))
  25.   (vars delay_time)
  26.   (fields ("delay_time" "delay_time")
  27.       ("aistate"    "state")
  28.       )
  29.   (states "art/misc.spe" 
  30.       (stopped "0_delay")
  31.       (on_state "1_delay")))
  32.  
  33.  
  34. (def_char GATE_OR
  35.   (funs (ai_fun or_ai)
  36.     (draw_fun dev_draw))
  37.   (states "art/misc.spe" 
  38.       (stopped "0_or_gate")
  39.       (on_state "1_or_gate")))
  40.       
  41. (def_char GATE_AND
  42.   (funs (ai_fun and_ai)
  43.     (draw_fun dev_draw))
  44.   (states "art/misc.spe" 
  45.       (stopped "0_and_gate")
  46.       (on_state "1_and_gate")))
  47.       
  48.       
  49. (def_char GATE_NOT
  50.   (funs (ai_fun not_ai)
  51.     (draw_fun dev_draw))
  52.   (states "art/misc.spe" 
  53.       (stopped "0_not_gate")
  54.       (on_state "1_not_gate")))
  55.  
  56.       
  57. (def_char GATE_XOR
  58.   (funs (ai_fun xor_ai)
  59.     (draw_fun dev_draw))
  60.   (states "art/misc.spe" 
  61.       (stopped "0_xor_gate")
  62.       (on_state "1_xor_gate")))
  63.  
  64. (def_char GATE_PULSE
  65.   (funs (ai_fun pulse_ai)
  66.     (draw_fun dev_draw))
  67.   (vars time_left pulse_speed)
  68.   (fields ("pulse_speed" "pulse_speed"))
  69.   (states "art/misc.spe"
  70.       (stopped "0_pulse")
  71.       (on_state "1_pulse")))
  72.  
  73.       
  74. (def_char INDICATOR
  75.   (funs (ai_fun indicator_ai))
  76.   (states "art/misc.spe" 
  77.       (stopped "0_indicator")
  78.       (on_state "1_indicator")))
  79.     
  80. (defun indicator_ai ()
  81.   (if (> (total_objects) 0)
  82.       (if (eq (with_obj0 (aistate)) 0)
  83.       (progn
  84.         (set_state stopped)
  85.         (set_aistate 0))
  86.     (progn
  87.       (set_state on_state)
  88.       (set_aistate 1)))) T)
  89.  
  90. (defun xor_check (last_object stat)
  91.   (if (< last_object 0)
  92.       stat
  93.     (if (eq (with_object (get_object last_object) (aistate)) 0)
  94.     (xor_check (- last_object 1) stat)
  95.       (xor_check (- last_object 1) (not stat)))))
  96.  
  97. (defun xor_ai ()
  98.   (if (xor_check (- (total_objects) 1) nil)
  99.       (progn
  100.     (set_state on_state)
  101.     (set_aistate 1))
  102.     (progn
  103.       (set_state stopped)
  104.       (set_aistate 0))) T)
  105.  
  106. (defun or_check (last_object)
  107.   (if (< last_object 0)
  108.       nil
  109.     (if (eq (with_object (get_object last_object) (aistate)) 0)
  110.     (or_check (- last_object 1))
  111.       T)))
  112.  
  113. (defun or_ai ()
  114.   (if (or_check (- (total_objects) 1))
  115.       (progn
  116.     (set_state on_state)
  117.     (set_aistate 1))
  118.     (progn
  119.       (set_state stopped)
  120.       (set_aistate 0))) T)
  121.  
  122.     
  123. (defun and_check (last_object)
  124.   (if (< last_object 0)
  125.       T
  126.     (if (eq (with_object (get_object last_object) (aistate)) 0)
  127.     nil
  128.       (and_check (- last_object 1)))))
  129.    
  130.  
  131. (defun and_ai ()
  132.   (if (and_check (- (total_objects) 1))
  133.       (progn
  134.     (set_state on_state)
  135.     (set_aistate 1))
  136.     (progn
  137.       (set_state stopped)
  138.       (set_aistate 0))) T)
  139.  
  140.  
  141. (defun not_ai ()
  142.   (if (> (total_objects) 0)
  143.       (if (eq (with_obj0 (aistate)) 0)
  144.       (progn
  145.         (set_state on_state)
  146.         (set_aistate 1))
  147.     (progn
  148.       (set_state stopped)
  149.       (set_aistate 0)))) T)
  150.  
  151. (defun pulse_ai ()
  152.   (if (> (total_objects) 0)
  153.       (if (not (eq (with_obj0 (aistate)) 0))
  154.       (if (eq time_left 0)
  155.           (if (eq (aistate) 0)
  156.           (progn
  157.             (setq time_left pulse_speed)
  158.             (set_state on_state)
  159.             (set_aistate 1))
  160.         (progn
  161.           (set_state stopped)
  162.           (set_aistate 0)))
  163.         (setq time_left (- time_left 1)))))
  164.   T)
  165.  
  166.